home *** CD-ROM | disk | FTP | other *** search
- //: C03:Enum.cpp
- // From Thinking in C++, 2nd Edition
- // Available at http://www.BruceEckel.com
- // (c) Bruce Eckel 1999
- // Copyright notice in Copyright.txt
- // Keeping track of shapes.
-
- enum ShapeType {
- circle,
- square,
- rectangle
- }; // Must end with a semicolon like a struct
-
- int main() {
- ShapeType shape = circle;
- // Activities here....
- // Now do something based on what the shape is:
- switch(shape) {
- case circle: /* circle stuff */ break;
- case square: /* square stuff */ break;
- case rectangle: /* rectangle stuff */ break;
- }
- } ///:~
-